package com.lhs.Controller;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.lhs.Result.Result;
import com.lhs.service.User_PointService;
import com.lhs.entity.user.User_point;
import com.lhs.entity.user.User_point_log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/user_point")
public class User_PointController {

    @Autowired
    private User_PointService user_pointService;

    /**
     * 获取用户积分
     * @return 用户积分
     */
    @GetMapping("/getUserPoint")
    public Result<User_point> getUserPoint(){
        return user_pointService.getUserPoint();
    }

    /**
     * 增加或减少积分
     * @return 用户积分
     */
    @GetMapping("/addOrSubtractPoint")
    public Result<User_point> addOrSubtractPoint(@RequestBody Long userId, Integer point){
        return user_pointService.addOrSubtractPoint(userId,point);
    }
   /**
     用户积分记录
    * @return 用户积分记录
    * */

    @GetMapping("/getUserPointRecord")
    public Result<User_point_log> getUserPointRecord(){
        return user_pointService.getUserPointRecord();
    }

// TODO:   管理员接口
    @SaCheckRole("admin-1")
    @GetMapping("/getUserPoint_Admin")
    public Result<User_point> getUserPoint_Admin(@RequestBody Long userId){
        return user_pointService.getUserPoint_Admin(userId);
    }
}
